<%--
  @author Tharanga Punchihewa
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<script type="text/javascript">
    $(document).ready(function() {

        /*var tt = document.getElementById("test").value;
         alert("TEst="+tt);*/


        var pls_enter_user_full_name = "<br>" + document.getElementById("pls_enter_user_full_name").value;
        var pls_enter_user_address = "<br>" + document.getElementById("pls_enter_user_address").value;
        var pls_enter_valid_email = "<br>" + document.getElementById("pls_enter_valid_email").value;
        var pls_enter_valid_phone_No = "<br>" + document.getElementById("pls_enter_valid_phone_No").value;
        var pls_enter_valid_NIC_No = "<br>" + document.getElementById("pls_enter_valid_NIC_No").value;
        var pls_enter_email_address = "<br>" + document.getElementById("pls_enter_email_address").value;
        $("#create-user").validate({
            rules: {
                fullNameId: {
                    required: true
                },
                addressId:{
                    required:true
                },
                personNIC:{
                    NICNo:true
                },
                landPhoneId:{
                    phoneNo:true
                },
                mobileId:{
                    phoneNo:true
                },
                emailId:{
                    required:true,
                    email:true
                }

            },
            messages: {
                fullNameId:pls_enter_user_full_name,
                addressId :pls_enter_user_address,
                personNIC:pls_enter_valid_NIC_No,
                landPhoneId:pls_enter_valid_phone_No,
                mobileId:pls_enter_valid_phone_No,
                emailId:{
                    required:pls_enter_email_address,
                    email:pls_enter_valid_email
                }

            }
        });
    });
</script>

<div id="user-module-home-title" class="module-home-title">

    <s:a href="home.do"><img src="${pageContext.request.contextPath}/images/home.png"
                                    alt="User Module"><span><s:label
            value="%{getText('home.label')}"/></span></s:a>
    <span class="module-title-breaker"> > </span>

    <s:if test="editMode == 1">

        <s:a href="urmgoiUserList.do"><img src="${pageContext.request.contextPath}/images/update-user.png"
                                                  alt="User Module"><span><s:label
                value="%{getText('modify_personal_details_by_urmgoi')}"/></span></s:a>
    </s:if>
    <s:elseif test="editMode == 2">

        <s:a href="#"><img src="${pageContext.request.contextPath}/images/update-user.png"
                           alt="User Module"><span><s:label
                value="%{getText('modify_personal_details_by_urmgoi')}"/></span></s:a>
    </s:elseif>
    <s:else>
        <s:a href="#"><img src="${pageContext.request.contextPath}/images/update-user.png"
                           alt="User Module"><span><s:label
                value="%{getText('register_ur-mgoi_users.label')}"/></span></s:a>
    </s:else>


</div>
<%--<div id="create-user-div">--%>
<s:if test="edit == 1">
    <h2><s:label value="%{getText('update_ur-mgoi_users.label')}"/></h2>
</s:if>
<s:elseif test="editMode == 2">
    <h2><s:label value="%{getText('modify_personal_details_by_urmgoi')}"/></h2>
</s:elseif>
<s:else>
    <h2><s:label value="%{getText('register_ur-mgoi_users.label')}"/></h2>
</s:else>


<hr/>
<s:form id="create-user" name="create-user" action="createURMGOIUsers.do" method="POST">
    <table>
        <tr>
            <td colspan="3" class="left-align">
                <div class="action-msg"><s:actionmessage/></div>
                <div class="action-err"><s:actionerror/></div>
            </td>
        </tr>
        <tr>
            <td class="left-align">
                <s:label value="%{getText('full_name.label')}"/> :<span class="mandatory-field"></span>
            </td>
            <td colspan="2" class="right-align">
                <s:textarea name="userDetail.name" id="fullNameId" cssClass="width-635-px"/>
            </td>
        </tr>
        <tr>
            <td class="left-align">
                <s:label value="%{getText('address.label')}"/> :<span class="mandatory-field"></span>
            </td>
            <td colspan="2" class="right-align">
                <s:textarea name="userContacts.address" id="addressId" cssClass="width-635-px"/>
            </td>
        </tr>
        <tr>
            <td class="left-align"><s:label value="%{getText('NIC_number.label')}"/></td>
            <td colspan="2" class="left-align"><s:textfield name="userDetail.personNIC" id="personNIC"/></td>
        </tr>
        <tr>
            <td rowspan="2"><s:label value="%{getText('telephone.label')}"/></td>
            <td><s:label value="%{getText('mobile.label')}"/> :</td>
            <td><s:textfield name="userContacts.mobile" id="mobileId"/></td>
        </tr>
        <tr>
            <td><s:label value="%{getText('land_phone.label')}"/> :</td>
            <td><s:textfield name="userContacts.landPhone" id="landPhoneId"/></td>
        </tr>
        <tr>
            <td class="left-align"><s:label value="%{getText('email.label')}"/> :<span class="mandatory-field"></span>
            </td>
            <td colspan="2" class="left-align"><s:textfield name="userContacts.email" id="emailId"/></td>
        </tr>
        <tr>
            <s:hidden name="organizationId"/>
            <s:hidden name="editMode"/>


            <td colspan="3" class="right-align">
                <s:if test="editMode==1 || editMode==2">
                    <s:hidden name="urmgoiUser.id"/>
                    <s:hidden name="userContacts.id"/>
                    <s:hidden name="userDetail.id"/>
                    <s:submit value="%{getText('edit.label')}"/>
                </s:if>
                <s:else>
                    <s:submit value="%{getText('register.label')}"/>
                </s:else>
            </td>
        </tr>
    </table>
</s:form>
<%--
</div>--%>
<s:hidden id="pls_enter_user_full_name" value="%{getText('pls_enter_user_full_name.label')}"/>
<s:hidden id="pls_enter_user_address" value="%{getText('pls_enter_user_address.label')}"/>
<s:hidden id="pls_enter_valid_email" value="%{getText('pls_enter_valid_email')}"/>
<s:hidden id="pls_enter_valid_phone_No" value="%{getText('pls_enter_valid_phone_No')}"/>
<s:hidden id="pls_enter_valid_NIC_No" value="%{getText('pls_enter_valid_NIC_No')}"/>
<s:hidden id="pls_enter_email_address" value="%{getText('pls_enter_email_address.label')}"/>
